import { computed } from 'vue'
import type { Rule } from 'ant-design-vue/es/form'

/**
 * 获取通知表单验证规则
 * @returns 通知表单验证规则对象
 */
export const useNotificationFormRules = () => {
  const { t } = useI18n()
  
  return computed<Record<string, Rule[]>>(() => ({
    title: [
      { required: true, message: t('notification.titleRequired'), trigger: 'blur' },
      { max: 100, message: t('notification.titleLength'), trigger: 'blur' }
    ],
    type: [
      { required: true, message: t('notification.typeRequired'), trigger: 'change' }
    ],
    level: [
      { required: true, message: t('notification.levelRequired'), trigger: 'change' }
    ],
    targetUserId: [
      { required: true, message: t('notification.receiverRequired'), trigger: 'change' }
    ],
    content: [
      { required: true, message: t('notification.contentRequired'), trigger: 'blur' },
      { max: 500, message: t('notification.contentLength'), trigger: 'blur' }
    ],
    link: [
      { 
        pattern: /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w.-]*)*\/?$/,
        message: t('notification.linkInvalid'), 
        trigger: 'blur' 
      }
    ]
  }))
} 